<style>
	tr.sub_row{background:#CCC;}
	tr.sub_row td{padding-left:20px;}
</style>
<div style="padding-bottom:20px;" class="button_section">
	<!--<form>
    	<input type="text"><input type="submit" value="search">
    </form>-->
       <div class="left width65p componentheading"><?php echo $page_title;?></div>
          <a class="button" href="<?php echo site_url('member/add')?>">Add New Members</a>
        <div class="clear"></div>
</div>
<div class="box-header">Member List</div>
<table width="100%">
	<thead>
      <tr>
            <th width="5%" height="32">Id</th>
            <th width="40%" height="32">Name</th>
            <th width="20%">Address</th>
            <th width="20%">Contact Number</th>
            <th width="5%">Status</th>
            <th width="10%">Action</th>
      </tr>
   </thead>
   <tbody>
      <?php if(count($members) > 0): ?>
      <?php foreach($members as $member) : ?>
            <tr>
            	<td><?php echo $member->id;?></td>
                <td>
                <div><?php echo $member->first_name." ".$member->last_name;?></div>
                <div>(<a href="mailto:<?php echo $member->email;?>"><?php echo $member->email;?></a>)</div>

                </td>
                <td>
                    <div><?php echo "".$member->address1;?></div>
                    <div><?php echo "".$member->address2;?></div>
                </td>
                <td>
                    <div><?php echo "Phone1: ".$member->phone1;?></div>
                    <div><?php echo "Phone2: ".$member->phone2;?></div>
                </td>
                <td><?php echo $member->status;?></td>
                <td><a href="<?php echo site_url('member/edit/'.$member->id)?>">Edit</a>
                <?php if(is_super_admin()) : ?>&nbsp;|&nbsp;
                    <a href="javascript:;" onClick="delete_member('<?php echo $member->id;?>');">Delete</a>
                <?php endif; ?>
                </td>
            </tr>
            
      <?php endforeach; ?>
      <?php else: ?>
      	<tr>
        	<td colspan="3">
      		<div class="error_message">
            	No members have been added.
            </div>
            </td>
        </tr>
      <?php endif; ?>
    </tbody>  
</table>
<div id="pagination">
	<?php echo $this->pagination->create_links(); ?>
</div>
<script>
	function delete_member(cid)
	{ 
		if(confirm('Are You Sure???'))	
		{
			$.post( '<?php echo site_url('member/delete');?>', {member_id : cid}, function(data){ window.location = '<?php echo current_url();?>';});
		}
	}
</script>